home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
cmln0786.arc
/
TPROLOG2.LTG
< prev
Wrap
Text File
|
1986-04-26
|
896b
|
44 lines
LISTING 2
Database Access Benchmark
/* Test database storage and retrieval by asserting lots of facts and lookingè them up. */
DATABASE
fact(INTEGER)
PREDICATES
test(INTEGER)
test2(INTEGER, INTEGER)
CLAUSES
/* Tail recursively look up a numbered fact in the database and the assert
its successor. First argument is current fact number, second argument
is limiting fact number to stop at. */
test2(X,X).
test2(X,Y) :- fact(X), Z = X + 1, assert(fact(Z)), test2(Z,Y).
/* Shorthand predicate to default the test to start with fact(1). */
test(Y) :- test2(1,Y).
fact(1). /* Seed the database with the first fact */
GOAL
/* Prompt for the limiting fact number and run the benchmark. */
nl, write(ready), nl, readint(X), test(X), write(done), nl.